package com.geeguo.ebuilder.core.swagger;

import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.info.Contact;
import io.swagger.v3.oas.models.info.Info;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class SwaggerConfig {

    /**
     * 接口文档标题
     */
    @Value("${springdoc.info.title}")
    private String title;

    /**
     * 接口文档描述
     */
    @Value("${springdoc.info.description}")
    private String description;

    /**
     * 接口文档版本
     */
    @Value("${springdoc.info.version}")
    private String version;

    /**
     * 作者
     */
    @Value("${springdoc.info.contact.name}")
    private String contactName;

    @Bean
    public OpenAPI springShopOpenAPI() {
        return new OpenAPI().info(new Info()
                        .title(title)
                        .description(description)
                        .version(version)
                        .contact(new Contact().name(contactName))
                );
    }
}